<?php

namespace App\Common\Exception\Handler;

use App\Common\Exception\ApiDataException;
use App\Common\Exception\ApiMessageException;
use App\Common\Exception\ExceptionHandlerInterface;

/**
 * Class ApiResponseExceptionHandler
 */
class ApiResponseExceptionHandler implements ExceptionHandlerInterface
{
    private ApiMessageException|ApiDataException|\Throwable $throwable;

    public function __construct(\Throwable $throwable)
    {
        $this->throwable = $throwable;
    }

    public function handle(): mixed
    {
        return $this->throwable->response();
    }

    public function isStop(): bool
    {
        return true;
    }
}
